/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('pai-dsw', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model Cluster {
  clusterId?: string(name='ClusterId', description='集群id'),
  clusterType?: string(name='ClusterType', description='集群类型'),
  config?: string(name='Config', description='集群配置'),
  name?: string(name='Name', description='集群名称'),
  nas?: string(name='Nas', description='nas文件id'),
  owner?: string(name='Owner', description='集群owner'),
  privateContainerPath?: string(name='PrivateContainerPath', description='个人nas挂载到容器路径'),
  privateNasPath?: string(name='PrivateNasPath', description='个人nas挂载路径'),
  publicContainerPath?: string(name='PublicContainerPath', description='公共nas挂载到容器的路径'),
  publicNasPath?: string(name='PublicNasPath', description='公共nas挂载路径'),
  state?: string(name='State', description='集群状态'),
  vSwitchId?: string(name='VSwitchId', description='集群vSwitch'),
  vpcId?: string(name='VpcId', description='集群vpc'),
}

model Config {
  name?: string(name='Name', description='配置名称'),
  value?: string(name='Value', description='配置数值'),
}

model Dataset {
  datasetId?: string(name='DatasetId', description='数据集id'),
  defaultMountPath?: string(name='DefaultMountPath', description='默认挂载路径'),
  fileSystemId?: string(name='FileSystemId', description='文件系统Id'),
  mountPath?: string(name='MountPath', description='挂载路径'),
  name?: string(name='Name', description='数据集名称'),
  nasPath?: string(name='NasPath', description='文件系统被挂载路径'),
}

model EcsSpec {
  cpu?: long(name='Cpu', description='cpu数量'),
  gpu?: long(name='Gpu', description='gpu卡数'),
  gpuType?: string(name='GpuType', description='GPU卡类型'),
  instanceType?: string(name='InstanceType', description='实例类型'),
  memoryInGiB?: long(name='MemoryInGiB', description='内存(GiB)'),
  systemDiskCategory?: string(name='SystemDiskCategory', description='磁盘类型'),
  systemDiskSizeInGiB?: long(name='SystemDiskSizeInGiB', description='磁盘大小(GiB)'),
}

model Image {
  acceleratorType?: string(name='AcceleratorType', description='资源类型'),
  author?: string(name='Author', description='镜像作者'),
  cudaVersion?: string(name='CudaVersion', description='Cuda版本'),
  description?: string(name='Description', description='镜像描述'),
  ecsImageKey?: string(name='EcsImageKey', description='Ecs镜像key'),
  framework?: string(name='Framework', description='算法框架'),
  frameworkVersion?: string(name='FrameworkVersion', description='算法框架版本'),
  fromImageId?: string(name='FromImageId', description='镜像父镜像'),
  fromImageName?: string(name='FromImageName', description='镜像名称'),
  gmtCreateTime?: string(name='GmtCreateTime', description='创建时间'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='修改时间'),
  imageId?: string(name='ImageId', description='镜像ID'),
  imageName?: string(name='ImageName', description='镜像名称'),
  imageUrl?: string(name='ImageUrl', description='镜像url'),
  instanceId?: string(name='InstanceId', description='实例ID'),
  namespace?: string(name='Namespace', description='镜像命名空间'),
  OS?: string(name='OS', description='镜像操作系统分发版'),
  OSVersion?: string(name='OSVersion', description='分发版版本'),
  pythonVersion?: string(name='PythonVersion', description='python版本'),
  region?: string(name='Region', description='地区'),
  repository?: string(name='Repository', description='镜像仓库'),
  repositoryPage?: string(name='RepositoryPage', description='跳转的镜像站点页面'),
  resourceType?: long(name='ResourceType', description='资源类型'),
  rootImageId?: string(name='RootImageId', description='镜像的根镜像'),
  shared?: boolean(name='Shared', description='镜像是否被其他实例共享'),
  shortImageUrl?: string(name='ShortImageUrl', description='镜像短url'),
  shortRepository?: string(name='ShortRepository', description='镜像仓库短名称'),
  stage?: string(name='Stage', description='镜像状态'),
  stageCode?: long(name='StageCode', description='镜像状态代码'),
  suggestedName?: string(name='SuggestedName', description='保存镜像建议的名称'),
  tag?: string(name='Tag', description='Tag'),
  type?: string(name='Type', description='镜像类型'),
  workspaceImageId?: string(name='WorkspaceImageId', description='工作空间镜像id'),
}

model ImageNamespace {
  namespace?: string(name='Namespace', description='命名空间名称'),
  namespaceStatus?: string(name='NamespaceStatus', description='命名空间状态'),
}

model ImageRepository {
  gmtCreateTime?: string(name='GmtCreateTime', description='创建时间'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='修改时间'),
  regionId?: string(name='RegionId', description='地区Id'),
  repoName?: string(name='RepoName', description='仓库名称'),
  repoNamespace?: string(name='RepoNamespace', description='仓库命名空间'),
  repoStatus?: string(name='RepoStatus', description='仓库状态'),
  repository?: string(name='Repository', description='仓库地址'),
}

model Instance {
  accumulativeRunningTimeInMillis?: long(name='AccumulativeRunningTimeInMillis', description='运行时间，毫秒数'),
  accumulativeRunningTimeInMinutes?: long(name='AccumulativeRunningTimeInMinutes', description='累计运行时间(分钟)'),
  createUser?: string(name='CreateUser', description='创建者'),
  datasetList?: [
    Dataset
  ](name='DatasetList', description='数据集列表'),
  ecsSpec?: string(name='EcsSpec', description='ecs规格'),
  gmtCreateTime?: string(name='GmtCreateTime', description='创建时间(GMT)'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='修改时间(GMT)'),
  imageId?: string(name='ImageId', description='镜像ID'),
  imageName?: string(name='ImageName', description='镜像名称'),
  imageType?: string(name='ImageType', description='镜像类型'),
  imageUrl?: string(name='ImageUrl', description='镜像链接'),
  instanceId?: string(name='InstanceId', description='实例ID'),
  instanceName?: string(name='InstanceName', description='实例名称'),
  instanceShutdownTimer?: InstanceShutdownTimer(name='InstanceShutdownTimer', description='定时关机任务'),
  instanceStatus?: string(name='InstanceStatus', description='实例状态'),
  instanceUrl?: string(name='InstanceUrl', description='dsw实例链接'),
  instanceVersion?: string(name='InstanceVersion', description='实例版本'),
  isPublic?: long(name='IsPublic', description='是否他人可见'),
  jupyterlabUrl?: string(name='JupyterlabUrl', description='jupyter链接'),
  message?: string(name='Message', description='错误消息'),
  nasFileSystemId?: string(name='NasFileSystemId', description='nas文件系统ID'),
  payType?: long(name='PayType', description='付费类型代码'),
  payTypeName?: string(name='PayTypeName', description='付费类型名称'),
  resource?: string(name='Resource', description='资源类型名称'),
  resourceType?: long(name='ResourceType', description='资源类型代码'),
  shutdownEnabled?: boolean(name='ShutdownEnabled', description='是否支持定时关机'),
  terminalUrl?: string(name='TerminalUrl', description='命令行终端链接'),
  userId?: string(name='UserId', description='用户ID'),
  userImageList?: [
    Image
  ](name='UserImageList', description='保存用户镜像列表'),
  userVpc?: UserVpc(name='UserVpc', description='被打通VPC配置'),
  webIdeUrl?: string(name='WebIdeUrl', description='webIde链接'),
  workspaceId?: string(name='WorkspaceId', description='工作空间id'),
  workspaceName?: string(name='WorkspaceName', description='工作空间名称'),
}

model InstanceShutdownTimer {
  gmtCreateTime?: string(name='GmtCreateTime', description='定时关机修改时间'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='定时关机创建时间'),
  instanceId?: string(name='InstanceId', description='实例ID'),
  scheduleTime?: string(name='ScheduleTime', description='定时关机时间'),
  ttlInMillis?: long(name='TtlInMillis', description='多少毫秒后定时关机（如果设定可以覆盖ScheduleTime）'),
}

model InstanceSnapshot {
  gmtCreateTime?: string(name='GmtCreateTime', description='实例快照保存时间（GMT）'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='实例快照修改时间（GMT）'),
  instanceId?: string(name='InstanceId', description='实例ID'),
  instanceSnapshotDescription?: string(name='InstanceSnapshotDescription', description='实例快照描述'),
  instanceSnapshotId?: string(name='InstanceSnapshotId', description='实例快照ID'),
  instanceSnapshotName?: string(name='InstanceSnapshotName', description='实例快照名称'),
  instanceSnapshotRepoUrl?: string(name='InstanceSnapshotRepoUrl', description='实例快照存储地址'),
  instanceSnapshotStatus?: string(name='InstanceSnapshotStatus', description='实例快照状态'),
  instanceSnapshotTag?: string(name='InstanceSnapshotTag', description='实例快照标签'),
}

model InstanceStatus {
  accumulativeRunningTimeInMinutes?: long(name='AccumulativeRunningTimeInMinutes', description='累计运行时间（分钟）'),
  instanceId?: string(name='InstanceId', description='实例ID'),
  instanceShutdownTimer?: InstanceShutdownTimer(name='InstanceShutdownTimer'),
  instanceStatus?: string(name='InstanceStatus', description='实例状态'),
  msg?: string(name='Msg', description='实例消息'),
  shutdownEnabled?: boolean(name='ShutdownEnabled', description='是否允许使用定时关机'),
  type?: string(name='Type', description='实例类型'),
}

model InstanceType {
  cpuCoreCount?: long(name='CpuCoreCount', description='CPU核数'),
  discount?: float(name='Discount', description='折扣'),
  domesticPrice?: float(name='DomesticPrice', description='内部价'),
  GPUAmount?: long(name='GPUAmount', description='GPU卡数'),
  GPUSpec?: string(name='GPUSpec', description='GPU规格'),
  instanceBandwidthRx?: long(name='InstanceBandwidthRx', description='实例接收带宽'),
  instanceBandwidthTx?: long(name='InstanceBandwidthTx', description='实例发送带宽'),
  instancePpsRx?: long(name='InstancePpsRx', description='实例每秒发包数量'),
  instancePpsTx?: long(name='InstancePpsTx', description='实例每秒收包数量'),
  instanceTypeFamily?: string(name='InstanceTypeFamily', description='实例规格族'),
  instanceTypeId?: string(name='InstanceTypeId', description='实例类型Id'),
  international?: boolean(name='International', description='是否国际站'),
  localStorageCapacity?: long(name='LocalStorageCapacity', description='本地磁盘容量'),
  memorySize?: float(name='MemorySize', description='内存容量'),
  price?: float(name='Price', description='价格'),
  priceCNY?: float(name='PriceCNY', description='价格（人民币）'),
  priceUSD?: float(name='PriceUSD', description='价格（美元）'),
  resourceType?: string(name='ResourceType', description='资源类型'),
  systemDiskCategory?: string(name='SystemDiskCategory', description='磁盘存储类型'),
  systemDiskSize?: long(name='SystemDiskSize', description='磁盘容量'),
}

model Nas {
  description?: string(name='Description', description='Nas盘描述'),
  fileSystemId?: string(name='FileSystemId', description='Nas文件系统Id'),
  status?: string(name='Status', description='Nas盘状态'),
}

model Region {
  regionCity?: string(name='RegionCity', description='城市'),
  regionId?: string(name='RegionId', description='id'),
  regionName?: string(name='RegionName', description='名称'),
  regionState?: string(name='RegionState', description='州省'),
  serviceUrl?: string(name='ServiceUrl', description='服务地址'),
}

model ResourceInfo {
  name?: string(name='Name', description='显卡类型'),
  payType?: long(name='PayType', description='支付类型'),
  resourceType?: long(name='ResourceType', description='资源类型'),
}

model SecurityGroup {
  createTime?: string(name='CreateTime', description='创建时间'),
  description?: string(name='Description', description='描述'),
  securityGroupId?: string(name='SecurityGroupId', description='安全组id'),
  securityGroupName?: string(name='SecurityGroupName', description='名称'),
  vpcId?: string(name='VpcId', description='vpc id'),
}

model Status {
  accumulativeRunningTimeInMinutes?: long(name='AccumulativeRunningTimeInMinutes', description='累计运行时间（分钟）'),
  instanceId?: string(name='InstanceId', description='实例ID'),
  instanceShutdownTimer?: InstanceShutdownTimer(name='InstanceShutdownTimer'),
  instanceStatus?: string(name='InstanceStatus', description='实例状态'),
  msg?: string(name='Msg', description='实例消息'),
  type?: string(name='Type', description='实例类型'),
}

model UserVpc {
  roleArn?: string(name='RoleArn', description='角色标识码'),
  securityGroupId?: string(name='SecurityGroupId', description='安全组ID'),
  vpcId?: string(name='VpcId', description='虚拟网络ID'),
  vswitchId?: string(name='VswitchId', description='虚拟交换机ID'),
}

model VSwitch {
  availableIpAddressCount?: long(name='AvailableIpAddressCount', description='可用ip数量'),
  cidrBlock?: string(name='CidrBlock', description='子网'),
  createTime?: string(name='CreateTime', description='创建时间'),
  description?: string(name='Description', description='描述'),
  isDefault?: boolean(name='IsDefault', description='是否默认'),
  status?: string(name='Status', description='状态'),
  vSwitchId?: string(name='VSwitchId', description='VSwitch Id'),
  vSwitchName?: string(name='VSwitchName', description='名称'),
  vpcId?: string(name='VpcId', description='vpc id'),
  zoneId?: string(name='ZoneId', description='可用区'),
}

model Vpc {
  cidrBlock?: string(name='CidrBlock', description='vpc子网'),
  createTime?: string(name='CreateTime', description='创建时间'),
  description?: string(name='Description', description='vpc描述'),
  isDefault?: boolean(name='IsDefault', description='是否默认'),
  status?: string(name='Status', description='vpc状态'),
  VRouterId?: string(name='VRouterId', description='路由id'),
  vpcId?: string(name='VpcId', description='vpc id'),
  vpcName?: string(name='VpcName', description='vpc名称'),
}

model CreateInstanceRequest {
  datasetList?: [
    Dataset
  ](name='DatasetList'),
  ecsSpec?: string(name='EcsSpec', description='实例规格'),
  environments?: map[string]any(name='Environments', description='环境参数'),
  imageId?: string(name='ImageId', description='镜像id'),
  imageUrl?: string(name='ImageUrl', description='镜像地址'),
  instanceName?: string(name='InstanceName', description='实例名称'),
  isPublic?: long(name='IsPublic'),
  nasFileSystemId?: string(name='NasFileSystemId', description='nas文件系统id'),
  userName?: string(name='UserName', description='实例的真实用户名称'),
  userVpc?: UserVpc(name='UserVpc', description='打通的vpc网络配置'),
  workspaceId?: string(name='WorkspaceId'),
}

model CreateInstanceResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model CreateInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateInstanceResponseBody(name='body'),
}

async function createInstance(request: CreateInstanceRequest): CreateInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createInstanceWithOptions(request, headers, runtime);
}

async function createInstanceWithOptions(request: CreateInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.datasetList)) {
    body['DatasetList'] = request.datasetList;
  }
  if (!Util.isUnset(request.ecsSpec)) {
    body['EcsSpec'] = request.ecsSpec;
  }
  if (!Util.isUnset(request.environments)) {
    body['Environments'] = request.environments;
  }
  if (!Util.isUnset(request.imageId)) {
    body['ImageId'] = request.imageId;
  }
  if (!Util.isUnset(request.imageUrl)) {
    body['ImageUrl'] = request.imageUrl;
  }
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.isPublic)) {
    body['IsPublic'] = request.isPublic;
  }
  if (!Util.isUnset(request.nasFileSystemId)) {
    body['NasFileSystemId'] = request.nasFileSystemId;
  }
  if (!Util.isUnset(request.userName)) {
    body['UserName'] = request.userName;
  }
  if (!Util.isUnset(request.userVpc)) {
    body['UserVpc'] = request.userVpc;
  }
  if (!Util.isUnset(request.workspaceId)) {
    body['WorkspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateInstance',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model CreateInstanceShutdownTimerRequest {
  scheduleTime?: string(name='ScheduleTime', description='定时关机时间（GMT）'),
  ttlInMillis?: long(name='TtlInMillis', description='多少毫秒后定时关机（如果设定可以覆盖ScheduleTime）'),
}

model CreateInstanceShutdownTimerResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model CreateInstanceShutdownTimerResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateInstanceShutdownTimerResponseBody(name='body'),
}

async function createInstanceShutdownTimer(InstanceId: string, request: CreateInstanceShutdownTimerRequest): CreateInstanceShutdownTimerResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createInstanceShutdownTimerWithOptions(InstanceId, request, headers, runtime);
}

async function createInstanceShutdownTimerWithOptions(InstanceId: string, request: CreateInstanceShutdownTimerRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateInstanceShutdownTimerResponse {
  Util.validateModel(request);
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var body : map[string]any= {};
  if (!Util.isUnset(request.scheduleTime)) {
    body['ScheduleTime'] = request.scheduleTime;
  }
  if (!Util.isUnset(request.ttlInMillis)) {
    body['TtlInMillis'] = request.ttlInMillis;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateInstanceShutdownTimer',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/shutdownTimer`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model CreateInstanceSnapshotRequest {
  instanceSnapshotDescription?: string(name='InstanceSnapshotDescription', description='实例快照描述'),
  instanceSnapshotName?: string(name='InstanceSnapshotName', description='实例快照名称'),
  instanceSnapshotRepoUrl?: string(name='InstanceSnapshotRepoUrl', description='实例快照存储地址（可选）'),
}

model CreateInstanceSnapshotResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  instanceSnapshotId?: string(name='InstanceSnapshotId', description='实例快照ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model CreateInstanceSnapshotResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateInstanceSnapshotResponseBody(name='body'),
}

async function createInstanceSnapshot(InstanceId: string, request: CreateInstanceSnapshotRequest): CreateInstanceSnapshotResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createInstanceSnapshotWithOptions(InstanceId, request, headers, runtime);
}

async function createInstanceSnapshotWithOptions(InstanceId: string, request: CreateInstanceSnapshotRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateInstanceSnapshotResponse {
  Util.validateModel(request);
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var body : map[string]any= {};
  if (!Util.isUnset(request.instanceSnapshotDescription)) {
    body['InstanceSnapshotDescription'] = request.instanceSnapshotDescription;
  }
  if (!Util.isUnset(request.instanceSnapshotName)) {
    body['InstanceSnapshotName'] = request.instanceSnapshotName;
  }
  if (!Util.isUnset(request.instanceSnapshotRepoUrl)) {
    body['InstanceSnapshotRepoUrl'] = request.instanceSnapshotRepoUrl;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateInstanceSnapshot',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/snapshots`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model DeleteInstanceResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model DeleteInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteInstanceResponseBody(name='body'),
}

async function deleteInstance(InstanceId: string): DeleteInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteInstanceWithOptions(InstanceId, headers, runtime);
}

async function deleteInstanceWithOptions(InstanceId: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteInstanceResponse {
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DeleteInstance',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model DeleteInstanceShutdownTimerResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model DeleteInstanceShutdownTimerResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteInstanceShutdownTimerResponseBody(name='body'),
}

async function deleteInstanceShutdownTimer(InstanceId: string): DeleteInstanceShutdownTimerResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteInstanceShutdownTimerWithOptions(InstanceId, headers, runtime);
}

async function deleteInstanceShutdownTimerWithOptions(InstanceId: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteInstanceShutdownTimerResponse {
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DeleteInstanceShutdownTimer',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/shutdownTimer`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model DeleteInstanceSnapshotResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  instanceSnapshotId?: string(name='InstanceSnapshotId', description='实例快照ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model DeleteInstanceSnapshotResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteInstanceSnapshotResponseBody(name='body'),
}

async function deleteInstanceSnapshot(InstanceId: string, InstanceSnapshotId: string): DeleteInstanceSnapshotResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteInstanceSnapshotWithOptions(InstanceId, InstanceSnapshotId, headers, runtime);
}

async function deleteInstanceSnapshotWithOptions(InstanceId: string, InstanceSnapshotId: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteInstanceSnapshotResponse {
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  InstanceSnapshotId = OpenApiUtil.getEncodeParam(InstanceSnapshotId);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DeleteInstanceSnapshot',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/snapshots/${InstanceSnapshotId}`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetAuthorizationResponseBody = {
  authorizationFailedCode?: string(name='AuthorizationFailedCode', description='授权失败错误代码'),
  authorizationFailedMessage?: string(name='AuthorizationFailedMessage', description='授权失败错误消息'),
  authorized?: boolean(name='Authorized', description='是否已经给DSW服务账号授权'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model GetAuthorizationResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetAuthorizationResponseBody(name='body'),
}

async function getAuthorization(): GetAuthorizationResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getAuthorizationWithOptions(headers, runtime);
}

async function getAuthorizationWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GetAuthorizationResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetAuthorization',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/authorization`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetDashboardStatisticsRequest {
  workspaceId?: string(name='WorkspaceId', description='工作空间ID'),
}

model GetDashboardStatisticsResponseBody = {
  instanceTotal?: long(name='InstanceTotal', description='实例数'),
  instsanceRunningTotal?: long(name='InstsanceRunningTotal', description='运行实例数'),
  requestId?: string(name='RequestId', description='Id of the request'),
}

model GetDashboardStatisticsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetDashboardStatisticsResponseBody(name='body'),
}

async function getDashboardStatistics(request: GetDashboardStatisticsRequest): GetDashboardStatisticsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getDashboardStatisticsWithOptions(request, headers, runtime);
}

async function getDashboardStatisticsWithOptions(request: GetDashboardStatisticsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetDashboardStatisticsResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.workspaceId)) {
    query['WorkspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetDashboardStatistics',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/statistics/dashboard`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetInstanceResponseBody = {
  accumulativeRunningTimeInMinutes?: long(name='AccumulativeRunningTimeInMinutes', description='累计运行时间(分钟)'),
  ecsSpec?: string(name='EcsSpec', description='ecs规格'),
  gmtCreateTime?: string(name='GmtCreateTime', description='实例创建时间(GMT)'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='实例修改时间(GMT)'),
  imageId?: string(name='ImageId', description='镜像ID'),
  imageUrl?: string(name='ImageUrl', description='镜像链接'),
  instanceId?: string(name='InstanceId', description='实例ID'),
  instanceName?: string(name='InstanceName', description='实例名称'),
  instanceShutdownTimer?: InstanceShutdownTimer(name='InstanceShutdownTimer', description='定时关机任务'),
  instanceStatus?: string(name='InstanceStatus', description='实例状态'),
  jupyterlabUrl?: string(name='JupyterlabUrl', description='jupyter链接'),
  nasFileSystemId?: string(name='NasFileSystemId', description='nas文件系统ID'),
  requestId?: string(name='RequestId', description='请求ID'),
  terminalUrl?: string(name='TerminalUrl', description='命令行终端链接'),
  userId?: string(name='UserId', description='用户ID'),
  userVpc?: UserVpc(name='UserVpc', description='被打通VPC配置'),
  webIdeUrl?: string(name='WebIdeUrl', description='web ide链接'),
}

model GetInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetInstanceResponseBody(name='body'),
}

async function getInstance(InstanceId: string): GetInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getInstanceWithOptions(InstanceId, headers, runtime);
}

async function getInstanceWithOptions(InstanceId: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetInstanceResponse {
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetInstance',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetInstanceShutdownTimerResponseBody = {
  gmtCreateTime?: string(name='GmtCreateTime', description='任务创建时间(GMT)'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='任务修改时间(GMT)'),
  instanceId?: string(name='InstanceId', description='实例ID'),
  requestId?: string(name='RequestId', description='请求ID'),
  scheduleTime?: string(name='ScheduleTime', description='定时关机时间(GMT)'),
}

model GetInstanceShutdownTimerResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetInstanceShutdownTimerResponseBody(name='body'),
}

async function getInstanceShutdownTimer(InstanceId: string): GetInstanceShutdownTimerResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getInstanceShutdownTimerWithOptions(InstanceId, headers, runtime);
}

async function getInstanceShutdownTimerWithOptions(InstanceId: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetInstanceShutdownTimerResponse {
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetInstanceShutdownTimer',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/shutdownTimer`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetInstanceSnapshotResponseBody = {
  gmtCreateTime?: string(name='GmtCreateTime', description='实例快照保存时间（GMT）'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='实例快照修改时间（GMT）'),
  instanceId?: string(name='InstanceId', description='实例ID'),
  instanceSnapshotDescription?: string(name='InstanceSnapshotDescription', description='实例快照描述'),
  instanceSnapshotId?: string(name='InstanceSnapshotId', description='实例快照ID'),
  instanceSnapshotName?: string(name='InstanceSnapshotName', description='实例快照名称'),
  instanceSnapshotRepoUrl?: string(name='InstanceSnapshotRepoUrl', description='实例快照存储地址'),
  instanceSnapshotStatus?: string(name='InstanceSnapshotStatus', description='实例快照状态'),
  instanceSnapshotTag?: string(name='InstanceSnapshotTag', description='实例快照标签'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model GetInstanceSnapshotResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetInstanceSnapshotResponseBody(name='body'),
}

async function getInstanceSnapshot(InstanceId: string, InstanceSnapshotId: string): GetInstanceSnapshotResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getInstanceSnapshotWithOptions(InstanceId, InstanceSnapshotId, headers, runtime);
}

async function getInstanceSnapshotWithOptions(InstanceId: string, InstanceSnapshotId: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetInstanceSnapshotResponse {
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  InstanceSnapshotId = OpenApiUtil.getEncodeParam(InstanceSnapshotId);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetInstanceSnapshot',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/snapshots/${InstanceSnapshotId}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetInstancesStatisticsRequest {
  workspaceIds?: string(name='WorkspaceIds', description='工作空间id列表'),
}

model GetInstancesStatisticsResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
  statistics?: map[string]any(name='Statistics', description='统计数据'),
}

model GetInstancesStatisticsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetInstancesStatisticsResponseBody(name='body'),
}

async function getInstancesStatistics(request: GetInstancesStatisticsRequest): GetInstancesStatisticsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getInstancesStatisticsWithOptions(request, headers, runtime);
}

async function getInstancesStatisticsWithOptions(request: GetInstancesStatisticsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetInstancesStatisticsResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.workspaceIds)) {
    query['WorkspaceIds'] = request.workspaceIds;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetInstancesStatistics',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/statistics/instances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ListEcsSpecsRequest {
  acceleratorTypeEquals?: string(name='AcceleratorTypeEquals', description='每页返回的实例数'),
}

model ListEcsSpecsResponseBody = {
  ecsSpecs?: [
    EcsSpec
  ](name='EcsSpecs', description='请求ecs规格列表'),
  requestId?: string(name='RequestId', description='请求ID'),
  totalCount?: long(name='TotalCount', description='符合要求的ecs规格数量'),
}

model ListEcsSpecsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListEcsSpecsResponseBody(name='body'),
}

async function listEcsSpecs(request: ListEcsSpecsRequest): ListEcsSpecsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listEcsSpecsWithOptions(request, headers, runtime);
}

async function listEcsSpecsWithOptions(request: ListEcsSpecsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListEcsSpecsResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.acceleratorTypeEquals)) {
    query['AcceleratorTypeEquals'] = request.acceleratorTypeEquals;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListEcsSpecs',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/ecsSpecs`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ListImagesRequest {
  acceleratorTypeEquals?: string(name='AcceleratorTypeEquals', description='资源类型'),
  imageNameContains?: string(name='ImageNameContains', description='容器名称关键字'),
  imageTypeEquals?: string(name='ImageTypeEquals', description='镜像类型'),
  product?: string(name='Product', description='产品'),
  workspaceId?: string(name='WorkspaceId', description='工作空间Id'),
}

model ListImagesResponseBody = {
  images?: [
    Image
  ](name='Images', description='镜像列表'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model ListImagesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListImagesResponseBody(name='body'),
}

async function listImages(request: ListImagesRequest): ListImagesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listImagesWithOptions(request, headers, runtime);
}

async function listImagesWithOptions(request: ListImagesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListImagesResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.acceleratorTypeEquals)) {
    query['AcceleratorTypeEquals'] = request.acceleratorTypeEquals;
  }
  if (!Util.isUnset(request.imageNameContains)) {
    query['ImageNameContains'] = request.imageNameContains;
  }
  if (!Util.isUnset(request.imageTypeEquals)) {
    query['ImageTypeEquals'] = request.imageTypeEquals;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['WorkspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListImages',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/images`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ListInstanceSnapshotsResponseBody = {
  instanceSnapshots?: [
    InstanceSnapshot
  ](name='InstanceSnapshots', description='镜像快照列表'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model ListInstanceSnapshotsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListInstanceSnapshotsResponseBody(name='body'),
}

async function listInstanceSnapshots(InstanceId: string): ListInstanceSnapshotsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listInstanceSnapshotsWithOptions(InstanceId, headers, runtime);
}

async function listInstanceSnapshotsWithOptions(InstanceId: string, headers: map[string]string, runtime: Util.RuntimeOptions): ListInstanceSnapshotsResponse {
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ListInstanceSnapshots',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/snapshots`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ListInstancesRequest {
  inWorkspace?: boolean(name='InWorkspace', description='是否在工作空间内查询'),
  instanceNameContains?: string(name='InstanceNameContains', description='实例名称关键字'),
  instanceStatusEquals?: string(name='InstanceStatusEquals', description='实例状态'),
  pageNumber?: string(name='PageNumber', description='当前页'),
  pageSize?: string(name='PageSize', description='每页返回的实例数'),
  sortBy?: string(name='SortBy', description='排序字段'),
  sortOrder?: string(name='SortOrder', description='升序降序'),
  workspaceIdEquals?: string(name='WorkspaceIdEquals', description='工作空间Id'),
}

model ListInstancesResponseBody = {
  instances?: [
    Instance
  ](name='Instances', description='实例列表'),
  pageNumber?: long(name='PageNumber', description='当前页'),
  pageSize?: long(name='PageSize', description='每页返回的实例数'),
  requestId?: string(name='RequestId', description='请求ID'),
  totalCount?: long(name='TotalCount', description='符合条件的实例数'),
}

model ListInstancesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListInstancesResponseBody(name='body'),
}

async function listInstances(request: ListInstancesRequest): ListInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listInstancesWithOptions(request, headers, runtime);
}

async function listInstancesWithOptions(request: ListInstancesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListInstancesResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.inWorkspace)) {
    query['InWorkspace'] = request.inWorkspace;
  }
  if (!Util.isUnset(request.instanceNameContains)) {
    query['InstanceNameContains'] = request.instanceNameContains;
  }
  if (!Util.isUnset(request.instanceStatusEquals)) {
    query['InstanceStatusEquals'] = request.instanceStatusEquals;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.sortBy)) {
    query['SortBy'] = request.sortBy;
  }
  if (!Util.isUnset(request.sortOrder)) {
    query['SortOrder'] = request.sortOrder;
  }
  if (!Util.isUnset(request.workspaceIdEquals)) {
    query['WorkspaceIdEquals'] = request.workspaceIdEquals;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListInstances',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ListInstancesStatusRequest {
  instanceIds?: string(name='InstanceIds', description='实例Id列表'),
}

model ListInstancesStatusResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
  statuses?: [
    InstanceStatus
  ](name='Statuses'),
}

model ListInstancesStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListInstancesStatusResponseBody(name='body'),
}

async function listInstancesStatus(request: ListInstancesStatusRequest): ListInstancesStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listInstancesStatusWithOptions(request, headers, runtime);
}

async function listInstancesStatusWithOptions(request: ListInstancesStatusRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListInstancesStatusResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.instanceIds)) {
    query['InstanceIds'] = request.instanceIds;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListInstancesStatus',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/statuses/instances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model StartInstanceResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model StartInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: StartInstanceResponseBody(name='body'),
}

async function startInstance(InstanceId: string): StartInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return startInstanceWithOptions(InstanceId, headers, runtime);
}

async function startInstanceWithOptions(InstanceId: string, headers: map[string]string, runtime: Util.RuntimeOptions): StartInstanceResponse {
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'StartInstance',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/start`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model StopInstanceRequest {
  saveImage?: boolean(name='SaveImage', description='是否保存镜像后停止'),
}

model StopInstanceResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model StopInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: StopInstanceResponseBody(name='body'),
}

async function stopInstance(InstanceId: string, request: StopInstanceRequest): StopInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return stopInstanceWithOptions(InstanceId, request, headers, runtime);
}

async function stopInstanceWithOptions(InstanceId: string, request: StopInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): StopInstanceResponse {
  Util.validateModel(request);
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var query : map[string]any= {};
  if (!Util.isUnset(request.saveImage)) {
    query['SaveImage'] = request.saveImage;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'StopInstance',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/stop`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model UpdateInstanceRequest {
  instanceName?: string(name='InstanceName', description='修改后实例名称'),
}

model UpdateInstanceResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model UpdateInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateInstanceResponseBody(name='body'),
}

async function updateInstance(InstanceId: string, request: UpdateInstanceRequest): UpdateInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateInstanceWithOptions(InstanceId, request, headers, runtime);
}

async function updateInstanceWithOptions(InstanceId: string, request: UpdateInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateInstanceResponse {
  Util.validateModel(request);
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  var body : map[string]any= {};
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateInstance',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model UpdateInstanceSnapshotRequest {
  instanceSnapshotName?: string(name='InstanceSnapshotName', description='实例快照名称'),
}

model UpdateInstanceSnapshotResponseBody = {
  instanceId?: string(name='InstanceId', description='实例ID'),
  instanceSnapshotId?: string(name='InstanceSnapshotId', description='实例镜像ID'),
  requestId?: string(name='RequestId', description='请求ID'),
}

model UpdateInstanceSnapshotResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateInstanceSnapshotResponseBody(name='body'),
}

async function updateInstanceSnapshot(InstanceId: string, InstanceSnapshotId: string, request: UpdateInstanceSnapshotRequest): UpdateInstanceSnapshotResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateInstanceSnapshotWithOptions(InstanceId, InstanceSnapshotId, request, headers, runtime);
}

async function updateInstanceSnapshotWithOptions(InstanceId: string, InstanceSnapshotId: string, request: UpdateInstanceSnapshotRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateInstanceSnapshotResponse {
  Util.validateModel(request);
  InstanceId = OpenApiUtil.getEncodeParam(InstanceId);
  InstanceSnapshotId = OpenApiUtil.getEncodeParam(InstanceSnapshotId);
  var body : map[string]any= {};
  if (!Util.isUnset(request.instanceSnapshotName)) {
    body['InstanceSnapshotName'] = request.instanceSnapshotName;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateInstanceSnapshot',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/${InstanceId}/snapshots/${InstanceSnapshotId}`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model UpdateV3InstanceByUserRequest {
  userId?: string(name='UserId'),
  workspaceId?: string(name='WorkspaceId'),
}

model UpdateV3InstanceByUserResponseBody = {
  code?: string(name='Code', description='状态码'),
  httpStatusCode?: int32(name='HttpStatusCode', description='http状态码'),
  idList?: [ long ](name='IdList'),
  message?: string(name='Message', description='说明'),
  requestId?: string(name='RequestId', description='请求Id'),
  success?: boolean(name='Success', description='成功标志'),
  userSet?: [ string ](name='UserSet'),
  workspaceId?: string(name='WorkspaceId'),
}

model UpdateV3InstanceByUserResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateV3InstanceByUserResponseBody(name='body'),
}

async function updateV3InstanceByUser(request: UpdateV3InstanceByUserRequest): UpdateV3InstanceByUserResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateV3InstanceByUserWithOptions(request, headers, runtime);
}

async function updateV3InstanceByUserWithOptions(request: UpdateV3InstanceByUserRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateV3InstanceByUserResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['WorkspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpdateV3InstanceByUser',
    version = '2021-02-26',
    protocol = 'HTTPS',
    pathname = `/api/v1/instances/migrate/user`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

